﻿<?php
/**
 * 轻云网络验证系统
 * =======================================================
 * 版权所有(C) 2019-2039 daenx.cn，并保留所有权利。
 * 作者：Daen大恩
 * 作者QQ: 1330166565
 * 开发群：661059773
 * =======================================================
 */
include 'data/weby.php';
?>
<?php
include 'head.php';
?>

    <title>自助后台-<?php echo $title?></title>
<link rel="shortcut icon" href="<?php echo $route?>img/LightCloud.png" type="image/x-icon" />
    <!-- Bootstrap core CSS -->
    <link href="<?php echo $route?>css/bootstrap.min.css" rel="stylesheet">
    <link href="<?php echo $route?>css/bootstrap-reset.css" rel="stylesheet">
    <!--external css-->
    <link href="<?php echo $route?>font-awesome/css/font-awesome.css"  rel="stylesheet"/>
    <!-- Custom styles for this template -->
    <link href="<?php echo $route?>css/style.css"  rel="stylesheet">
    <link href="<?php echo $route?>css/style-responsive.css" rel="stylesheet"/>
    <!--toastr-->
    <link href="<?php echo $route?>toastr-master/toastr.css" rel="stylesheet" type="text/css"/>
    <script language="JavaScript" src="<?php echo $route?>js/jquery-1.7.2.min.js"></script>
    <script language="JavaScript" src="<?php echo $route?>js/function.js"></script>
    <!-- HTML5 shim and Respond.js IE8 support of HTML5 tooltipss and media queries -->
    <!--[if lt IE 9]>
    <script src="<?php echo $route?>js/html5shiv.js" ></script>
    <script src="<?php echo $route?>js/respond.min.js" ></script>
    <![endif]-->
	<style>
	body{
		margin: 0 auto;
		text-align: center;
	}
	.container {
	  max-width: 580px;
	  padding: 15px;
	  margin: 0 auto;
	}
	.hzhz{
		float: left;
	}
	.bzbz {
	color: #31708f;
	background-color: rgba(217, 237, 247, 0.73);
	border-color: #bce8f1;

	padding: 15px;
	margin-bottom: 20px;
	border: 1px solid transparent;
	border-radius: 3px;
	}
	.form-controltm {
	display: block;
	width: 100%;
	height: 34px;
	padding: 6px 12px;
	font-size: 14px;
	line-height: 1.42857143;
	color: #555;
	background-color: rgba(255, 255, 255, 0.48);
	background-image: none;
	border: 1px solid #ccc;
	border-radius: 4px;
	-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075);
	box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075);
	-webkit-transition: border-color ease-in-out .15s, -webkit-box-shadow ease-in-out .15s;
	-o-transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s;
	transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s;
	}
	</style>
</head>

<body >

<section id="container" >

    <section id="main-content">
        <section class="wrapper">
           <div class="row">
<div class="col-md-6 col-md-offset-2">
                    <!--work progress start-->
                    <section class="panel">
                        <div class="panel-body progress-panel">
                            <div class="task-progress">
                                <h1>获取key</h1>
<?php
$submit = $_GET['submit'];
$user = $_GET['user'];
$pass = $_GET['pass'];
$cp = $_GET['ycp'];
	if($submit=="立即查询")
	{
		if($cp==null){echo("<script language=\"javascript\" type=\"text/javascript\" src=\"/data/assets/js/jquery.min.js\"></script><script language=\"javascript\" type=\"text/javascript\" src=\"/data/assets/layer/layer.js\"></script><script>layer.open({  type: 1  ,title: false   ,closeBtn: false  ,area: '200px;'  ,shade: 0.8  ,id: 'LAY_layuipro'   ,resize: false  ,btn: ['确定']  ,moveType: 1   ,content: '<div style=\"padding: 30px; line-height: 22px; background-color: #393D49; color: #fff; font-weight: 300;\">请选择一个产品</div>'  ,success: function(layero){ var btn = layero.find('.layui-layer-btn');  btn.find('.layui-layer-btn0').attr({ href: 'user_key.php' });  }});</script>");}
		else
		if($user==null){echo("<script language=\"javascript\" type=\"text/javascript\" src=\"/data/assets/js/jquery.min.js\"></script><script language=\"javascript\" type=\"text/javascript\" src=\"/data/assets/layer/layer.js\"></script><script>layer.open({  type: 1  ,title: false   ,closeBtn: false  ,area: '200px;'  ,shade: 0.8  ,id: 'LAY_layuipro'   ,resize: false  ,btn: ['确定']  ,moveType: 1   ,content: '<div style=\"padding: 30px; line-height: 22px; background-color: #393D49; color: #fff; font-weight: 300;\">账号不能为空</div>'  ,success: function(layero){ var btn = layero.find('.layui-layer-btn');  btn.find('.layui-layer-btn0').attr({ href: 'user_key.php' });  }});</script>");}
		else
		if($pass==null){echo("<script language=\"javascript\" type=\"text/javascript\" src=\"/data/assets/js/jquery.min.js\"></script><script language=\"javascript\" type=\"text/javascript\" src=\"/data/assets/layer/layer.js\"></script><script>layer.open({  type: 1  ,title: false   ,closeBtn: false  ,area: '200px;'  ,shade: 0.8  ,id: 'LAY_layuipro'   ,resize: false  ,btn: ['确定']  ,moveType: 1   ,content: '<div style=\"padding: 30px; line-height: 22px; background-color: #393D49; color: #fff; font-weight: 300;\">密码不能为空</div>'  ,success: function(layero){ var btn = layero.find('.layui-layer-btn');  btn.find('.layui-layer-btn0').attr({ href: 'user_key.php' });  }});</script>");}
		else
		$sql = "SELECT * FROM authorize WHERE domain='$user' and ycp='$cp'";
		$result = mysqli_query($con,$sql);
		$row=mysqli_fetch_array($result);
		if($row['yumi'] == '1')
		{
			echo("<script language=\"javascript\" type=\"text/javascript\" src=\"/data/assets/js/jquery.min.js\"></script><script language=\"javascript\" type=\"text/javascript\" src=\"/data/assets/layer/layer.js\"></script><script>layer.open({  type: 1  ,title: false   ,closeBtn: false  ,area: '200px;'  ,shade: 0.8  ,id: 'LAY_layuipro'   ,resize: false  ,btn: ['确定']  ,moveType: 1   ,content: '<div style=\"padding: 30px; line-height: 22px; background-color: #393D49; color: #fff; font-weight: 300;\">账户已被封禁<br>备注：".$row['bz']."</div>'  ,success: function(layero){ var btn = layero.find('.layui-layer-btn');  btn.find('.layui-layer-btn0').attr({ href: 'user_key.php' });  }});</script>");
		die();
		}
		$SQL = "SELECT * FROM `products` WHERE `cp`='$cp'";
		$query=mysqli_query($con,$SQL);
		$row =mysqli_fetch_array($query);
		$key_cp = $row[nkey];
		$data = array(
			'op' => 'get_key',
			'user' => $user,
			'pass' => $pass,
			'key_cp' => $key_cp,
		);

		function getSign($secret, $data) {
			// 对数组的值按key排序
			ksort($data);
			// 生成url的形式
			$params = http_build_query($data);
			// 生成sign
			$sign = md5($params . $secret);
			return $sign;
		}
		
		$params = '&sign='.getSign(md5($apikey), $data).'&timestamp='.time();
		$file_contents = file_get_contents('http://'.$_SERVER['HTTP_HOST'].'/api/api_url.php?op=get_key&user='.$user.'&pass='.$pass.'&key_cp='.$key_cp.''.$params);
		$arr = (array) json_decode($file_contents,true);
		if($arr['status'] == 0 or $arr['state'] == 0)
		echo("<script language=\"javascript\" type=\"text/javascript\" src=\"/data/assets/js/jquery.min.js\"></script><script language=\"javascript\" type=\"text/javascript\" src=\"/data/assets/layer/layer.js\"></script><script>layer.open({  type: 1  ,title: false   ,closeBtn: false  ,area: '200px;'  ,shade: 0.8  ,id: 'LAY_layuipro'   ,resize: false  ,btn: ['确定']  ,moveType: 1   ,content: '<div style=\"padding: 30px; line-height: 22px; background-color: #393D49; color: #fff; font-weight: 300;\">".$arr['message']."</div>'  ,success: function(layero){ var btn = layero.find('.layui-layer-btn');  btn.find('.layui-layer-btn0').attr({ href: 'user_key.php' });  }});</script>");
		else
		if($arr['state'] == 1)
		echo("<script language=\"javascript\" type=\"text/javascript\" src=\"/data/assets/js/jquery.min.js\"></script><script language=\"javascript\" type=\"text/javascript\" src=\"/data/assets/layer/layer.js\"></script><script>layer.open({  type: 1  ,title: false   ,closeBtn: false  ,area: '200px;'  ,shade: 0.8  ,id: 'LAY_layuipro'   ,resize: false  ,btn: ['确定']  ,moveType: 1   ,content: '<div style=\"padding: 30px; line-height: 22px; background-color: #393D49; color: #fff; font-weight: 300;\">查询成功，请记好<br>您的用户key：<br>".$arr['key_user']."</div>'  ,success: function(layero){ var btn = layero.find('.layui-layer-btn');  btn.find('.layui-layer-btn0').attr({ href: 'user_key.php' });  }});</script>");
	}
?>                              
                            
                        </div>
						</div>
						<div class="table  table-hover personal-task">
							<ul class="pagination"><a class="btn btn-info" href="user_user.php">修改账号</a> &nbsp;<a class="btn btn-primary" href="user_pass.php">修改密码</a> &nbsp;<a class="btn btn-success" href="user_name.php">修改用户名</a> &nbsp;<a class="btn btn-danger" href="user_key.php">获取key</a>&nbsp;</ul>
							</div>
                        <h3 class="form-signin-heading">您可能需要准备一些信息</h3>
	<form action="user_key.php" class="form-sign" method="get">
	 (为确保安全性，请选择对应产品并填写好账号密码)<br><br>
		 <div class="form-group">
                                <label for="txtDomain"></label>
                                <select name="ycp" class="form-control" >
								<option value=''>请选择产品 </option>
 									<?php 
										$sql="select * from products ORDER BY `id` DESC";
										$result=mysqli_query($con,$sql);
										if($result&&mysqli_num_rows($result)){
											while ($row=mysqli_fetch_assoc($result)) {
												if($row['qt']==1){
												echo "<option value='".$row['cp']."'>".$row['cp']."</option>";		}									
											}
										}
									?>   
									</select>
								</div>	
		 <input type="text" class="form-controltm" name="user" placeholder="请输入您的账号" value=""><br>
		 <input type="text" class="form-controltm" name="pass" placeholder="请输入您的密码" value=""><br>
		 <input type="submit" name="submit" class="btn btn-danger btn-block" value="立即查询">
	 </form>
	 <br>
                        <div class="container-fluid"> 
								<a class="btn btn-warning" href="index.php">返回首页</a> &nbsp;<a class="btn btn-primary" href="http://wpa.qq.com/msgrd?v=3&uin=<?=$kfqq?>&site=qq&menu=yes">联系客服</a>
   <p style="text-align:center"><br>&copy; Powered by <?php echo $title?></p></div>
                    </section>
                    <!--work progress end-->
                </div>
				

        </section>
    </section>
    <!--main content end-->
</section>


<!-- js placed at the end of the document so the pages load faster -->
<script src="<?php echo $route?>js/jquery.js" ></script>
<script src="<?php echo $route?>js/bootstrap.min.js" ></script>
<!--toastr-->
<script src="<?php echo $route?>toastr-master/toastr.js" ></script>

<script type="text/javascript" src="<?php echo $route?>jCryption/jquery.jcryption.3.1.0.js" ></script>


</body>
</html>
